import java.util.Arrays;
import java.util.Random;

public class quickSort {
    public static void main(String[] args) {
        Random random=new Random();
        int[] a=new int[11];
        for (int i = 0; i < 11; i++) {
            a[i]= random.nextInt(100);
        }
        System.out.println(Arrays.toString(a));
        quicksort(a,0, a.length-1);
        System.out.println(Arrays.toString(a));
    }
    private static void quicksort(int[] a,int begin,int end){
        if(begin>end)
            return;
        int i=begin;
        int j=end;
        int key=a[begin];
        while(i<j){
            while (i<j&&a[j]>key){
                j--;
            }
            if(i<j){
                a[i]=a[j];
                i++;
            }
            while (i<j&&a[i]<key){
                i++;
            }
            if(i<j){
                a[j]=a[i];
                j--;
            }
        }
        a[i]=key;
        quicksort(a,begin,i-1);
        quicksort(a,i+1,end);
    }
}
